﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Snowdreamist.Windows.Navigation.Primitives
{
    public class NavigationContext : IDisposable
    {
        public NavigationContext(
            NavigateProcessor processor,
            Uri uri,
            object viewModel,
            object view,
            Session session,
            Exception error
            )
        {
            if (processor == null)
                throw new ArgumentNullException("processor");

            this.Processor = processor;
            this.RequestUri = uri;
            this.View = view;
            this.ViewModel = viewModel;
            this.Session = session;
            this.Error = error;
        }

        /// <summary>
        /// The request uri
        /// </summary>
        public Uri RequestUri { get; set; }

        /// <summary>
        /// ViewModel
        /// </summary>
        public object ViewModel { get; set; }

        /// <summary>
        /// View
        /// </summary>
        public object View { get; set; }

        /// <summary>
        /// Null for new session
        /// </summary>
        public Session Session { get; set; }

        /// <summary>
        /// Error
        /// </summary>
        public Exception Error { get; set; }

        /// <summary>
        /// Processor
        /// </summary>
        public NavigateProcessor Processor { get; private set; }

        public void Dispose()
        {
            this.Processor.ViewModel = this.ViewModel;
            this.Processor.View = this.View;
        }
    }
}